package tests;

import common.Utils;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;

import java.io.IOException;

public class ListPage extends Utils {
    //列表页URL
    public static String url = "https://tieba.baidu.com/i/i/my_tie";
    public ListPage() {
        super(url);
    }


    //未登录状态下查看我的帖子
    public void ListNoLogin() throws IOException, InterruptedException {

        try{
            driver.findElement(By.cssSelector("#errorText > p"));
            System.out.println("未登录");
        }catch (NoSuchElementException e){

        }
        //屏幕截图
        Thread.sleep(1000);
        getPicture(getClass().getName());
        System.out.println("保存截图成功");
    }

    //登录状态下查看我的帖子
    public void ListSuccLogin() throws IOException, InterruptedException {
        try{
            driver.findElement(By.cssSelector("#main_header_logo > ul > li.nav_cur > a"));
            System.out.println("登录成功");
        }catch (NoSuchElementException e){
            System.out.println("登录失败");
        }
        //屏幕截图
        //强制等待1000毫秒
        Thread.sleep(1000);
        getPicture(getClass().getName());
        System.out.println("保存截图成功");
    }
}
